USE [Bases2]
GO
/****** Object:  StoredProcedure [dbo].[BuscarCliente]    Script Date: 10/11/2011 21:32:56 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[BuscarCliente]    
    @IdCliente int
AS 
BEGIN
	SET NOCOUNT ON
	DECLARE @Contador int;
	SET @Contador=0;
	
	BEGIN TRANSACTION 	   
    
    SELECT @Contador=COUNT(*)
    FROM CLIENTE WHERE id_cliente=@IdCliente
    
    IF @Contador=0
    BEGIN
		SELECT -1,'No existe ningun cliente con el codigo indicado.'
	END
	ELSE
	BEGIN
		SELECT *
		FROM CLIENTE WHERE id_cliente=@IdCliente
	END	
	COMMIT
	SET NOCOUNT OFF
END